package com.readpost.service.impl;


import com.readpost.service.MailService;
import com.readpost.utils.MailUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class MailServiceImpl implements MailService
{
    @Autowired
    private MailUtil mailUtil;

    @Override
    public boolean sendTestMail(String sendName, String receiveName, String title, String content){
        boolean result = mailUtil.sendMail(sendName, receiveName, title, content);
        if (result) {
            System.out.println("邮件发送成功");
        } else {
            System.out.println("邮件发送失败");
        }
        return result;
    }

    /*
      发送验证码
      @param email 邮箱
     * @return 验证码
     */
//    @Override
//    public MailDto sendAuthCode(String email) {
//        // 生成验证码
//         Random random = new Random();
//         int code = random.nextInt(9000) + 1000;
//         String authCode = String.valueOf(code);
//         MailUtil mailUtil = new MailUtil();
//         mailUtil.sendMail();
//
//
//    }
}
